
import './App.css';
import React, { useEffect } from 'react';
import {
  BrowserRouter,
  Route,
  Switch
} from 'react-router-dom'

import Login from '@/pages/Login/login';
import Proof from './pages/Proof/proof';
import { Redirect } from 'react-router-dom/cjs/react-router-dom.min';
import Apply from './pages/Loan/Apply/apply';
import Review from './pages/Loan/Review/review';
import Launch from './pages/Launch/launch';
import Reject from './pages/Loan/Reject/reject';
import Loaning from './pages/Loan/Loaning/loaning';
import Repay from './pages/Loan/Repay/repay';
import FingerprintJS from '@fingerprintjs/fingerprintjs'
import DeviceID from './utils/deviceId';
import ProofMobile from './pages/Proof/Mobile/mobileverify';
import ProofFrequentlyApps from './pages/Proof/FrequentlyApps/frequentlyapps';
import ProofFace from './pages/Proof/Face/face';
import LoginFB from './pages/Login/LoginFB';
import LoginAd from './pages/LoginAd/LoginAd';
import SmartChat from './utils/smartChat';
import PrivacyPolicy from './pages/PrivacyPolicy/PrivacyPolicy';
import Guide from './pages/Loan/Guide/Guide';
import Home from './pages/Home/home';
// import Install from './pages/Install/install';
import ProofContact from './pages/Proof/Contact/contactverify';
import ProofContactInput from './pages/Proof/Contact/contactverifyinput';

function App() {

  //初始化指纹
  useEffect(() => {

    window.addEventListener("onAppDidInstalled", (e) => {
      // Toast.show("onuacredit install success");
      console.log("found: onAppDidInstalled");
    });

    SmartChat.init();

    if (!DeviceID.isValidVistorId()) {
      const fpPromise = FingerprintJS.load();
      fpPromise.then(fp => fp.get()).then(result => {
        DeviceID.saveVisitorId(result.visitorId);
        console.log("launch fingerprint: " + result.visitorId);
      });
    }
  }, [])

  return (
    <BrowserRouter basename="/h5onuacredit">
      <div className="AppRoot">
        <div className="App">
          <Switch>
            <Route path="/proof"><Proof /></Route>
            <Route path="/proofmobile"><ProofMobile /></Route>
            <Route path="/prooffrequentlyapps"><ProofFrequentlyApps /></Route>
            <Route path="/proofface"><ProofFace /></Route>
            <Route path="/proofcontact"><ProofContact /></Route>
            <Route path="/proofcontactinput"><ProofContactInput /></Route>
            <Route path="/login"><Login /></Route>
            <Route path="/loginfb"><LoginFB /></Route>
            <Route path='/loginad' ><LoginAd /></Route>
            <Route path='/home' ><Home /></Route>
            <Route path='/apply' ><Apply /></Route>
            <Route path='/review' ><Review /></Route>
            <Route path='/reject' ><Reject /></Route>
            <Route path='/loaning' ><Loaning /></Route>
            <Route path='/repay' ><Repay /></Route>
            <Route path='/launch' ><Launch /></Route>
            <Route path='/privacy' ><PrivacyPolicy /></Route>
            <Route path='/guide' ><Guide /></Route>
            {/* <Route path='/install' ><Install /></Route> */}

            <Redirect to='/launch'></Redirect>
          </Switch>
        </div>
      </div>
    </BrowserRouter>
  );
}

export default App;
